/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.usecase.editpart;

import org.eclipse.draw2d.IFigure;

import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.figures.IconFigure;
import com.cea.papyrus.diagram.classdiagram.figures.ConstraintFigure;
import com.cea.papyrus.diagram.usecase.helper.EdgeExtendHelper;
import com.cea.papyrus.diagraminterchange2.di2.GraphNode;

/**
 * Represents the contraint.
 * Redefines ConstraintEditPart from package classdiagram to manage extend conditions.
 */
public class ConstraintEditPart extends com.cea.papyrus.diagram.classdiagram.editpart.ConstraintEditPart {

	/**
	 * Creates a new ContraintEditPart
	 * @param graphnode the graph node associated to this controller
	 * @param modelManager the model manager associated to the uml element
	 */
	public ConstraintEditPart(GraphNode graphNode, ModelManager modelManager) {
		super(graphNode, modelManager);
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.common.editpart.GraphNodeWithSemanticEditPart#createFigure()
	 */
	@Override
	protected IFigure createFigure() {
		// Force initialization of the manager when figure has changed
		manager = null;
		// Try to get figure from ContainerWithSemanticEditPart
		IFigure fig = super.createFigure();
		if (fig instanceof IconFigure) {
			return fig;
		}
		// else
		if (getUmlElement().getName().equals(EdgeExtendHelper.EXTEND_CONDITION_NAME)){
			return new ConstraintFigure();
		}
		return new ConstraintFigure();		
	}
}